using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;
using System.Web.UI;
using System.Web;

namespace Decav.Gatsb.Web.Controls
{
    public class NotLoggedInRibbonControl : WebControl
    {
        public NotLoggedInRibbonControl()
            : base(HtmlTextWriterTag.Div)
        {
        }

        protected override void OnPreRender(EventArgs e)
        {
            this.Visible = !HttpContext.Current.User.Identity.IsAuthenticated;

            if (this.CssClass == null || CssClass == string.Empty)
                this.CssClass = "StatusRibbon";

            base.OnPreRender(e);
        }

        protected override void RenderContents(HtmlTextWriter writer)
        {
            writer.Write("You are not logged in.  ");

            writer.AddAttribute(HtmlTextWriterAttribute.Href,
                string.Format("Login.aspx?ReturnUrl={0}", HttpContext.Current.Server.UrlEncode(HttpContext.Current.Request.RawUrl)));
            writer.RenderBeginTag(HtmlTextWriterTag.A);
            writer.Write("Login now");
            writer.RenderEndTag(); // A

            writer.Write(" to have full access to Gatsb.");

            writer.RenderBeginTag(HtmlTextWriterTag.Br);
            writer.RenderEndTag(); // br
            writer.Write("Not a member?  ");

            writer.AddAttribute(HtmlTextWriterAttribute.Href,
                string.Format("CreateAccount.aspx?ReturnUrl={0}", HttpContext.Current.Server.UrlEncode(HttpContext.Current.Request.RawUrl)));
            writer.RenderBeginTag(HtmlTextWriterTag.A);
            writer.Write("Sign up");
            writer.RenderEndTag(); // A
            writer.Write(" and share pictures and notes from your phone.");

            base.RenderContents(writer);
        }
    }
}
